package com.zhaozhe.singleton;

/**
 * 可继承的单例泛型
 *
 * Created by ghjou on 2018/3/7.
 */
public abstract class MSingleton<T> {
    private T mInstance;

    protected abstract T create();

    public final T get() {
        synchronized (this){
            if(mInstance == null){
                mInstance = create();
            }
            return  mInstance;
        }
    }
}
